<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<title>khutro.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="js/custom-form-elements.js"></script>
<SCRIPT type="text/javascript" src="js/items.js"></SCRIPT>
<link href="css/userpage.css" rel="stylesheet" type="text/css">
<link href="css/search.css" rel="stylesheet" type="text/css">
<link href="css/form.css" rel="stylesheet" type="text/css">
<link href="css/button.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
	function imgurl(){
		
		var name = document.getElementById('image').value;
		var url = window.location.host+'/FSH_Final/Img/Topic/'+name;
		
		fbsummit.elements['image'].value = url;
		alert('okie');
		
	}
</script>
<style type="text/css">
.ac_over {
	color: white; background-color:green;
}
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
	marginheight="0">
	<script src="//connect.facebook.net/en_US/all.js"></script>
	<form action="fbsummit" id="fbsummit" method="post">
		<!-- Save for Web Slices (khutroslide.psd) -->
		<div id="header">
		<div id="headerContent">
			<a href="index.action" id="logo">khutro</a>
			<ul id="menuBar">
				<li><a href="index.action">Trang chủ</a></li>
				<li><a href="help.jsp">Trợ giúp</a></li>
				<li><a href="checkaddtopic.action">Đăng cho thuê</a>
				<li><a href="checkaddsharetopic.action">Đăng chia sẻ</a>
				<li><a href="compareresult.action">So sánh<span
						id="numberCompare" style="color: red; font-size: 12px">(${number})</span>
				</a></li>
				
			</ul>
			
			<div id="loginPanel">
				<c:choose>
					<c:when test="${displayNamess!=null}">
						<a class="profileButton" href="profileuser.action">${displayNamess}
						</a>
						<ul>
							<c:choose>
								<c:when test="${userRoleIdss==1}">
									<li><a href="adminloadsystem.action">Trang quản lý</a>
								</c:when>
							</c:choose>
							<li><a href="profileuser.action">Trang cá nhân</a></li><li><a href="changepass.jsp">Đổi mật khẩu</a>
							</li>
							<li><a href="logout.jsp">Thoát</a>
							</li>
						</ul>
					</c:when>
					<c:otherwise>
						<a class="loginButton" href="login.jsp">Đăng nhập</a>
					</c:otherwise>
				</c:choose>
			</div>
			<div id="search">
			<DIV class="search-box">
			  <div style="width: 80%;float: left">
		      <INPUT id="lookup_input" class="search-bar" style="width: 220px;height: 24px;" name="keysearch" value="Tìm Kiếm ..." type="text">
		      </div>
		      <div style="width: 19%;float: right;">
		      <img alt="search" src="images/search.png" width="24" height="24" onclick="searchFull();">
		      </div>
				<SCRIPT type="text/javascript" src="js/searchfulltext.js"></SCRIPT>
		      
		      <FORM id="search-form" method="post" action="fulltextsearch.action">
		      	<INPUT id="sortby" class="search-bar" name="sortby" value="0" type="hidden">
		      </FORM>
      		</DIV>
			</div>  
		</div>
	</div>
	<script type="text/javascript">
	$('#lookup_input').bind('keypress', function(e) {
		if(e.keyCode==13){
			searchFull();
		}
	});
	</script>
		<img src="images/spacer.gif" width="1" height="56" alt="">
		<div id="contentmain">
			<div class="postcontent">
				<span style="text-align: center; "><h1 class="content" style="color: #034B8A;">Chia
						sẻ bài đăng của bạn trên mạng xã hội:</h1> </span>
				<!--info cus-->

				<!--end info-->
				<div id="confirmshare">
					<div style="width: 100%; float: left">
						<input type="checkbox" name="fb" id="fb" class="styled" value="fb" checked />Facebook
					</div>
					<div style="width: 100%; float: left">
						<input type="checkbox" name="gg" id="gg" class="styled" value="gg" disabled="disabled"/>G+
					</div>
				</div>
				<input type="hidden" name="title" id="title" value="${title }">
				<input type="hidden" name="address" id="address" value="${address }">
				<input type="hidden" name="image" id="image" value="${urlImg }">
				<script type="text/javascript">
				function returnindex(){
					document.location = 'index.action';
				}
				</script>
				<div class="summit" style="padding-left: 40%">
					<a href="JavaScript:void(0);" class="buttoncus" onclick="returnindex();">Bỏ qua</a> 
					<a href="JavaScript:void(0);" class="nextbt" id="fbshare" onclick="fb_postwall();">Chia sẻ</a>

				</div>
			</div>
		</div>
		<div id="footercus" style="text-align: center;">
		<em>Designed by FU team | Powered by Struts<br> khutro.net</em>

	</div>
		<input type="hidden" name="postfbwall" value="postfbwall" />
		<!-- End Save for Web Slices -->
	</form>

	<script type="text/javascript">
	
		function fb_postwall() {
			
			//imgurl();
			
			if (document.getElementById('fb').checked){
				
					FB
							.getLoginStatus(function(response) {
								if (response.status === 'connected') {
									postfb();
								} else {
									FB.login(function(response) {
										// handle the response
									}, {
										scope : 'email,publish_actions'
									});
								}
							});
					FB.Event.subscribe('auth.authResponseChange',
							function(response) {
								if (response.authResponse) {
									postfb();
								}
							});
				}
				
			}
			
		
		function postfb(){
			var my_message = 'Chỗ mình đang có phòng cho thuê đấy! ';
			var url = window.location.host+'/FSH_Final/detail.action?topicId='+${topicId}+'&districtId='+${districtId};
			
			var title = document.getElementById('title').value;
			var desc = document.getElementById('address').value;
			var picUrl = document.getElementById('image').value;
			
			FB
					.api(
							'/me/feed',
							'post',
							{
								message : my_message,
								link : url,
								name : title,
								picture : picUrl,
								description : desc
							},
							function(response) {
								window.location.href = "index.action";
							});
		}
		
	</script>
	<script type="text/javascript">
		window.fbAsyncInit = function() {
			FB.init({
				appId : '418620964854308',
				status : true,
				cookie : true,
				xfbml : true
			});


		};
	</script>
</body>
</html>